<?php
/**
 * @filename:					GraveyardTypeAction.class.php
 * @desc:						墓型管理模块
 *
 * @author: 					张召
 * @copyright:					zhangzhao@huigeyuan.com
 * @date:						2011-04-19
 */


class GraveyardTypeAction extends CommonAction
{
    function _initialize() {
    	parent::_initialize();
        $burytype = D('bury_type');
        $buryname = $burytype->select();

        $gravetype = D('grave_type');
        $gravename = $gravetype->select();
        $multitype = D('grave_multi_type');
        $multiname = $multitype->select();

        $this->assign('buryname',$buryname);
        $this->assign('gravename',$gravename);
        $this->assign('multiname',$multiname);

    }
    /**
    * 墓型展示
    */
    function index()
    {
    	$crumb_info = array(
			array('uri' => '__URL__', 'title' => L('graveyardtype_manage'), 'sort' => C('CRUMB_LAST')),
		);

		$this->_mergeCrumbInfo($crumb_info);
		$this->_action_link = array(
			array('uri' => '__URL__/add', 'title' => L('add_graveyardtype')),
		);
		$this->assign('crumb_info', $this->_crumb_info);
		$this->assign('action_link', $this->_action_link);
		$listRows=$_REQUEST ['listRows'];
		parent::index();
    }
    /**
    * 添加新的墓型
    */
    public function add()
    {
       $crumb_info = array(
			array('uri' => '__URL__', 'title' => L('graveyardtype_manage'), 'sort' => C('CRUMB_DEFAULT')),
			array('uri' => '__URL__/add', 'title' => L('add_graveyardtype'), 'sort' => C('CRUMB_LAST')),
		);

		$this->_mergeCrumbInfo($crumb_info);
		$this->_action_link = array(
			array('uri' => '__URL__/index', 'title' => L('list_graveyardtype')),
			);

		$this->assign('crumb_info', $this->_crumb_info);
		$this->assign('action_link', $this->_action_link);

		parent::add();
    }

    /**
    * 查看墓型的详细信息
    */
    public function view()
    {
       $crumb_info = array(
			array('uri' => '__URL__', 'title' => L('graveyardtype_manage'), 'sort' => C('CRUMB_LAST')),
		);

		$this->_mergeCrumbInfo($crumb_info);
		$this->_action_link = array(
			array('uri' => '__URL__/index', 'title' => L('list_graveyardtype')),
		);
		$this->assign('crumb_info', $this->_crumb_info);
		$this->assign('action_link', $this->_action_link);
		parent::view();
    }

    /**
    * 修改或完善墓型信息
    */
    public function edit()
    {
       $crumb_info = array(
			array('uri' => '__URL__', 'title' => L('graveyardtype_manage'), 'sort' => C('CRUMB_DEFAULT')),
			array('uri' => '__URL__/edit/id/' . $_REQUEST['id'], 'title' => L('edit_graveyardtype'), 'sort' => C('CRUMB_LAST')),
		);

		$this->_mergeCrumbInfo($crumb_info);
		$this->_action_link = array(
			array('uri' => '__URL__/index', 'title' => L('list_graveyardtype')),
			);

		$this->assign('crumb_info', $this->_crumb_info);
		$this->assign('action_link', $this->_action_link);
		parent::edit();
    }

    /**
    * 删除当前墓型记录
    */
    public function delete()
    {
       parent::delete();
    }
	
	
	
	Public function upload(){   

		import("ORG.Net.UploadFile"); 
		$upload = new UploadFile(); // 实例化上传类  
		$upload->maxSize  = 3145728 ; // 设置附件上传大小 
		$upload->allowExts  = array('jpg', 'gif', 'png', 'jpeg'); // 设置附件上传类型  
		$upload->savePath =  './Public/Uploads/'; // 设置附件上传目录 
		if(!$upload->upload()) { // 上传错误 提示错误信息   
			$this->error($upload->getErrorMsg());  
		}else{ // 上传成功 获取上传文件信息 
			$info =  $upload->getUploadFileInfo(); 
		 }  
		// 保存表单数据 包括附件数据 
		$type = M("graveyard_type"); // 实例化对象 
		$type->create(); // 创建数据对象   
		$type->image_url = $info[0]["savename"]; // 保存上传的照片 根据需要自行组装 
		$type->add(); // 写入用户数据到数据库  
		$this->assign ( 'jumpUrl', Cookie::get ( '_currentUrl_' ) );
		$this->success("添加成功！"); 
		
	}  
		Public function upload1(){ 

		import("ORG.Net.UploadFile"); 
		$upload = new UploadFile(); // 实例化上传类  
		$upload->maxSize  = 3145728 ; // 设置附件上传大小 
		$upload->allowExts  = array('jpg', 'gif', 'png', 'jpeg'); // 设置附件上传类型  
		$upload->savePath =  './Public/Uploads/'; // 设置附件上传目录 
		if(!$upload->upload()) { // 上传错误 提示错误信息   
			$this->error($upload->getErrorMsg());  
		}else{ // 上传成功 获取上传文件信息 
			$info =  $upload->getUploadFileInfo(); 
		 }  
		// 保存表单数据 包括附件数据 
		$type = M("graveyard_type"); // 实例化对象 
		$type->create(); // 创建数据对象   
		$type->image_url = $info[0]["savename"]; // 保存上传的照片 根据需要自行组装 
		$type->save(); // 保存用户数据到数据库  
		$this->assign ( 'jumpUrl', Cookie::get ( '_currentUrl_' ) );
		$this->success("更新成功！"); 
		
	} 

}

?>